﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Templates/Template2.Master" 
Inherits="System.Web.Mvc.ViewPage<SushiWeb.Models.Producto>" %>



<asp:Content ID="Content2" ContentPlaceHolderID="menuContent" runat="server">
<%
    //string[] menuArray = { "0", "0", "0", "0", "1", "0","0" };
    string[] menuArray = { "0", "0", "0", "0", "1"};
    Session["menuArray"] = menuArray;
%>
</asp:Content>


<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">
   <script type="text/javascript">


       $(document).ready(function () {

           $(".datepicker").datepicker();
           // validar formulario
           //            $("#clienteForm").validate();
           $("#productoForm").validate({
               submitHandler: function (form) {
                   submitForm("");
               },
               rules: {
                   Nombre: "required",
                   Detalle: "required",
                   Porcion: "required",
                   Precio: "required",
                   TipoProducto: "required",
                   Imagen: "required"

               }
           });

       });

       function submitForm() {

           var $form = $("#productoForm");

           $.ajax({
               type: "POST",
               url: $form.attr('action'),
               data: $form.serialize(),
               error: function (xhr, status, error) {
                   $.msgBox({
                       content: error,
                       type: "error"
                   });
               },
               success: function (data) {
                   $("#loading-div-background").hide();
                   if (data.tipoMensaje == 'INFO') {
                       $.msgBox({
                           content: data.mensaje,
                           type: "info",
                           afterClose: function () {
                               window.location = data.redirectTo;
                           }
                       });
                   } else if (data.tipoMensaje == 'WARN') {
                       $.msgBox({
                           content: data.mensaje,
                           type: "alert"
                       });
                   }

               },
               beforeSend: function (data) {
                   $("#loading-div-background").show();
               }
           });

           return false;
       }

    </script>

    <h2 style="font-size: large">&nbsp;</h2>
    
    <% using (Html.BeginForm("ModificarProducto", "Producto", FormMethod.Post, new { id = "productoForm", @class = "cmxform" }))
       {%>   
        <table style="width:100%;">
            <tr>
                <td colspan="2" style="font-size: medium">
                    Modificar&nbsp; Productos&nbsp;</td>
                    <%: Html.TextBoxFor(model => model.IdProducto, new { @style = "display:none;" })%>
            </tr>
            <tr>
                <td style="width: 124px">
                    Nombre :</td>
                <td>
                    <%: Html.TextBoxFor(model => Model.Nombre)%></td>
            </tr>
            <tr>
                <td style="width: 124px">
                    Detalle:</td>
                <td>
                     <%: Html.TextAreaFor(model => Model.Detalle)%>
                </td>
            </tr>
            <tr>
                <td style="width: 124px">
                    Porción:
                </td>
                <td>
                    <%: Html.TextBoxFor(model => Model.Porcion)%>
                </td>
            </tr>
            <tr>
                <td style="width: 124px">
                    Precio:</td>
               <td>
                    <%: Html.TextBoxFor(model => Model.Precio)%>
                </td>
            </tr>
            <tr>
                <td style="width: 124px">
                    Tipo Producto :</td>
                <td>
                    <%: Html.TextBoxFor(model => Model.TipoProducto)%>
                </td>
            </tr>
            <tr>
                <td style="width: 124px">
                    Imagen :</td>
                <td>
                   <!-- <: Html.TextBoxFor(model => Model.Imagen, new { type = "file", @class = "textFile"})%>-->
                   <!-- <input type="file" name="Subir Imagen" id="FileUpload" /> -->
                   <%: Html.TextBoxFor(model => Model.Imagen)%> 
                </td>
            </tr>
            
            <tr>
                
                <td colspan="2" style="text-align: right">
                       <input id="btnSubmit" type="submit" value="Actualizar" class="button" />
                </td>
                
            </tr>
        </table>
      
       <% } %>
</asp:Content>
